package org.tony.thread.demo;

import java.awt.AWTEvent;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.PointerInfo;
import java.awt.Toolkit;
import java.awt.event.AWTEventListener;

public class MouseDemo extends Thread
{
	public void run()
	{
		while (true)
		{
			PointerInfo pointInfo = MouseInfo.getPointerInfo();
			Point position = pointInfo.getLocation();
			// System.out.println("current:-->(" + position.x + "," + position.y
			// + ")");
			try
			{
				Thread.currentThread().sleep(1000);
			}
			catch (InterruptedException e)
			{
				e.printStackTrace();
			}
		}

	}

	public static void main(String[] args)
	{
		new MouseDemo().start();
		Toolkit.getDefaultToolkit().addAWTEventListener(new MyMouseMonitorListener(), 1000);
	}

	public static class MyMouseMonitorListener implements AWTEventListener
	{

		public void eventDispatched(AWTEvent event)
		{
			System.out.println(event.getClass().getName());
		}

	}
}
